#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "car_opr.h"
#include <stropts.h>


int main(int argc, char** argv) {

	int  car_fd;
	// char pin_stat;

	printf("haha\n");

	car_fd = open("/dev/car", O_RDWR);

	if (car_fd == -1) {
		printf("open err \n");
		return -1;
	}

	while (1) {

		// pin_stat = 1;
		// if (write(car_fd, &pin_stat, 1) != 1)
		// 	printf("write err \n");
		ioctl(car_fd,MOVE_FORWARD);
		sleep(1);
		ioctl(car_fd,TURN_LEFT);
		sleep(1);
		ioctl(car_fd,RESTORE_DIRECTION);
		sleep(1);
		ioctl(car_fd,TURN_RIGHT);
		sleep(1);
		ioctl(car_fd,RESTORE_DIRECTION);
		sleep(1);
		ioctl(car_fd,SLIDE);
		sleep(1);
		ioctl(car_fd,BRAKE);
		sleep(1);
		ioctl(car_fd,MOVE_BACKWARD);
		sleep(1);
		ioctl(car_fd,SLIDE);
		sleep(1);
		ioctl(car_fd,BRAKE);
		sleep(1);

		// pin_stat = 0;
		// if (write(car_fd, &pin_stat, 1) != 1)
		// 	printf("write err \n");
		// sleep(3);
	}

	return 0;
}